cmake_minimum_required(VERSION 3.10)
project(BrainfuckIDE)

# 设置 C++ 标准
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

# Linux 编译器设置
if(UNIX AND NOT APPLE)
    add_compile_options(-Wall -Wextra -Wpedantic)
    # 链接 pthread
    find_package(Threads REQUIRED)
endif()

# 创建可执行文件
add_executable(brainfuck_ide
    brainfuck_ide.cpp
)

# Linux 库链接
if(UNIX AND NOT APPLE)
    target_link_libraries(brainfuck_ide 
        Threads::Threads
    )
endif()

# 设置输出目录
set_target_properties(brainfuck_ide PROPERTIES
    RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
)

# 创建运行目标
add_custom_target(run
    COMMAND brainfuck_ide
    DEPENDS brainfuck_ide
    WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bin
    COMMENT "运行 Brainfuck IDE"
)

message(STATUS "构建 Linux Brainfuck IDE")
message(STATUS "编译器: ${CMAKE_CXX_COMPILER}")
message(STATUS "构建类型: ${CMAKE_BUILD_TYPE}")